package com.ease.kit.jamon;

import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;

import javax.sql.DataSource;

import com.jamonapi.proxy.MonProxyFactory;

/**
 * 
 * @author nathanleewei
 * 
 */
public class JamonDataSource implements DataSource {

	public boolean isWrapperFor(Class<?> iface) throws SQLException {

		return false;
	}

	public <T> T unwrap(Class<T> iface) throws SQLException {

		return null;
	}

	public DataSource target;

	public Connection getConnection() throws SQLException {
		return MonProxyFactory.monitor(target.getConnection());
	}

	public Connection getConnection(String username, String password) throws SQLException {
		return MonProxyFactory.monitor(target.getConnection(username, password));
	}

	public int getLoginTimeout() throws SQLException {
		return target.getLoginTimeout();
	}

	public PrintWriter getLogWriter() throws SQLException {
		return target.getLogWriter();
	}

	public void setLoginTimeout(int seconds) throws SQLException {
		target.setLoginTimeout(seconds);
	}

	public void setLogWriter(PrintWriter out) throws SQLException {
		target.setLogWriter(out);
	}

	/**
	 * @return Returns the target.
	 */
	public DataSource getTarget() {
		return target;
	}

	/**
	 * @param target
	 *            The target to set.
	 */
	public void setTarget(DataSource target) {
		this.target = target;
	}
}
